package com.dehui.traders.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dehui.traders.R;
import com.dehui.traders.utils.BaseRecyclerAdapter;
import com.dehui.traders.utils.SmartViewHolder;

import java.util.Collection;

import me.goldze.mvvmhabit.utils.Utils;

/**
 * Created by hqq on 18.4.18.
 */

public class HomeDataAdapter extends BaseRecyclerAdapter<String>{

    private Context context;
    private int selectPos = 1;

    public HomeDataAdapter(Context context, Collection<String> collection, int layoutId,AdapterView.OnItemClickListener listener) {
        super(collection, layoutId,listener);
        this.context=context;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder holder, String model, int position) {
        TextView tvTitle = holder.findViewById(R.id.tv_title);
        LinearLayout llContainer = holder.findViewById(R.id.ll_container);
        TextView tvName = holder.findViewById(R.id.tv_name);
        TextView tvIndex = holder.findViewById(R.id.tv_index);
        int widthPixels = Utils.getScreen(context).widthPixels;
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) llContainer.getLayoutParams();
        lp.width = widthPixels / 3;
        llContainer.setLayoutParams(lp);

        tvTitle.setText("10667.1");
        tvName.setText("上证指数");
        tvIndex.setText("0.80%");

        if (position == selectPos){
            tvTitle.setTextSize(17);
            tvName.setTextSize(16);
            tvIndex.setTextSize(13);
        }else{
            tvTitle.setTextSize(16);
            tvName.setTextSize(15);
            tvIndex.setTextSize(12);
        }

    }


    public void setSelectPos(int selectPos) {
        this.selectPos = selectPos;
        this.notifyDataSetChanged();
    }
}
